#!/usr/bin/env perl

use File::Basename;
use strict;
use Config;
use Data::Dumper;

@::A=qw(
	addtag
	ci
	co
	diff
	dump
	get
	info
	removetag
	sha1sum
	status
	unlock
	upgrade
	);

$::P=".";
$::W=0;
if($::Config{osname} =~ /mswin/i) {
	$::W=1;
}

if(dirname($0) ne "." && length(dirname($0))) {
	$::P=dirname($0);
}

if(! @::ARGV || ! grep {$_ eq $::ARGV[0]} @::A) {
	print "The following sub-commands are available:\n";
	for my $c (sort(@::A)) {
		print "* $c\n";
	}
	exit(1);
}

{
my @N=();
	for my $c (@::ARGV) {
		if($c =~ /\s+/) {
			push @N,"\"$c\"";
		} else {
			push @N,$c;
		}
	}
	@::ARGV=@N;
}

my $c="$::P/pv3_$::ARGV[0] " . join(" ",@::ARGV[1 .. $#::ARGV]);

if($::W) {
	$c="perl.exe -I$::P $c";
} else {
	$c="perl -I$::P $c";
}

system($c);exit($?>>8);

